const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    intPageSize:15,
    intCurrPage:1,
    key:'',
    searchno:false,
    list:[],
    noMore:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      key:options.key
    })
    this.getNewsList();
  },
  toInfo:function (e) {
    wx.navigateTo({
      url: 'newsinfo?tid='+e.currentTarget.dataset.tid
    })  
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  getNewsList:function () {
    var that = this;
    var api_input = {
      type:'k',
      Key:this.data.key,
      strCity:'',
      strProvice:'',
      intPageSize:that.data.intPageSize,
      intCurrPage:that.data.intCurrPage
    }     
    app.getDaoPost('api/FeijiuApp/Post_FJ_GetToutiaoList',api_input,function (r) {
      if (r.code == 200) {
        if (r.data.length > 0) {
          for (var i = 0; i < r.data.length; i++) {
            r.data[i].addtime = r.data[i].addtime.replace('T'," ").substring(5,16);
            if (r.data[i].photo) {
              r.data[i].photo = app.photoSplitOne(r.data[i].photo)
            }
          }
          var list1 = that.data.list.concat(r.data);
          that.setData({
            list:list1,
            intCurrPage:that.data.intCurrPage+1
          })
        }else{
          that.setData({
            noMore:true,
            searchno:true
          })          
        }       
      }
    }) 
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (!this.data.noMore) {
      this.getNewsList();
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})